cmake_minimum_required(VERSION 3.10)

project(testSo)

execute_process(
    COMMAND pwd
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build"
)

message(STATUS "current CMAKE_BUILD_TYPE:${CMAKE_BUILD_TYPE}")
if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
    add_definitions(-DDebug)
endif()
message(STATUS "current CMAKE_BUILD_TYPE:${CMAKE_BUILD_TYPE}")


if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
    # set(CMAKE_CXX_FLAGS_DEBUG "-O0 -Wall -g -ggdb")
    add_definitions(-O0 -fopenmp -fPIC)
    add_definitions(-DDebug)
    message(STATUS "current run Debug")
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
    # set(CMAKE_CXX_FLAGS_DEBUG "-O3 ")
    add_definitions(-O3 -fopenmp -fPIC)
    add_definitions(-DRelease)
    message(STATUS "current run Release")
endif()

find_package(PkgConfig REQUIRED QUIET)#QUIET找不到库才报错

find_package(glfw3 REQUIRED)
find_package(GLEW REQUIRED)

# find_library(glTextEffect libglTextEffect.a ${CMAKE_CURRENT_SOURCE_DIR}/../src/core/gltxt/lib)

# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../src assgl)


include(../src/Utils.cmake)
pkgCheckModulesFun(FFMPEGLIB "libavcodec libavformat libavutil libswresample libswscale libavfilter")
pkgCheckModulesFun(ASSGLLIB "libassgl")



include_directories(
    /usr/include/freetype2
    /usr/local/include
    ${FFMPEGLIB_INCLUDE_DIRS}
    ${ASSGLLIB_INCLUDE_DIRS}
    
    # ${CMAKE_CURRENT_SOURCE_DIR}/../src
    # ${CMAKE_CURRENT_SOURCE_DIR}/../src/core/gltxt/include

)

link_directories(
    # ${CMAKE_CURRENT_SOURCE_DIR}/../src/core/gltxt/lib
)

message("PROJECT_NAME:${PROJECT_NAME}")
file(GLOB project_file main.c 
    )

add_executable(${PROJECT_NAME} ${project_file})

# target_include_directories(${PROJECT_NAME} PRIVATE ${Libassgl_INCLUDE_DIRS})

target_link_libraries(${PROJECT_NAME}
    -Wl,--start-group
    pthread m dl stdc++
    -lglfw
    -lGL
    -lm
    -lXrandr
    -lX11
    -lpthread
    -ldl
    glut

    icuuc
    harfbuzz

    freetype GLEW::GLEW  freeimage
    

    ${FFMPEGLIB_LIBRARIES}
    ${ASSGLLIB_LIBRARIES}
    
    # ${glTextEffect}
    # assgl
    
    # ${Libassgl_LIBRARIES}
    
    -Wl,--end-group

    )


